using System;
using System.Data.Common;

namespace EFMetaProvider
{
    public class EFMetaProviderFactory : DbProviderFactory, IServiceProvider
    {
        [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "Factory class is immutable.")]
        public static readonly EFMetaProviderFactory Instance = new EFMetaProviderFactory();

        public override bool CanCreateDataSourceEnumerator
        {
            get { return false; }
        }

        public override DbCommand CreateCommand()
        {
            return null;
        }

        public override DbCommandBuilder CreateCommandBuilder()
        {
            throw new NotSupportedException();
        }

        public override DbConnection CreateConnection()
        {
            return new EFMetaConnection();
        }

        public override DbConnectionStringBuilder CreateConnectionStringBuilder()
        {
            throw new NotSupportedException();
        }

        public override DbDataAdapter CreateDataAdapter()
        {
            throw new NotSupportedException();
        }

        public override DbDataSourceEnumerator CreateDataSourceEnumerator()
        {
            return System.Data.Sql.SqlDataSourceEnumerator.Instance;
        }

        public override DbParameter CreateParameter()
        {
            throw new NotSupportedException();
        }

        public object GetService(Type serviceType)
        {
        	if (serviceType == typeof(DbProviderServices))
            {
                return EFMetaProviderServices.Instance;
            }
        	return null;
        }
    }
}
